package com.hfut.jpoa.dao.impl;

import java.sql.SQLException;

import com.hfut.jpoa.common.exception.DaoException;
import com.hfut.jpoa.dao.ProjectDAO;
import com.hfut.jpoa.model.Project;
import com.ibatis.sqlmap.client.SqlMapClient;

public class ProjectDAOImpl implements ProjectDAO {
    private SqlMapClient sqlMapClient;

   

    public int deleteByPrimaryKey(String projectId) throws DaoException {
        Project key = new Project();
        key.setProjectId(projectId);
        int rows = 0;
        try {
            rows = sqlMapClient.delete("tb_jpoa_project.ibatorgenerated_deleteByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    public void insert(Project record) throws DaoException {
        try {
            sqlMapClient.insert("tb_jpoa_project.ibatorgenerated_insert", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void insertSelective(Project record) throws DaoException {
        try {
            sqlMapClient.insert("tb_jpoa_project.ibatorgenerated_insertSelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public Project selectByPrimaryKey(String projectId) throws DaoException {
        Project key = new Project();
        key.setProjectId(projectId);
        Project record = null;
        try {
            record = (Project) sqlMapClient.queryForObject("tb_jpoa_project.ibatorgenerated_selectByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return record;
    }

    public int updateByPrimaryKeySelective(Project record) throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_jpoa_project.ibatorgenerated_updateByPrimaryKeySelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    public int updateByPrimaryKey(Project record) throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_jpoa_project.ibatorgenerated_updateByPrimaryKey", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }

    /**
    * @param 对sqlMapClient进行赋值
    */
    public void setSqlMapClient(SqlMapClient sqlMapClient) {
        this.sqlMapClient = sqlMapClient;
    }
}